#include "head.h"

#define VALUE 3

union  semun {
    int val;
    struct semid_ds *buf;
    unsigned short *array;
    struct seminfo *__buff;
};

int main(int argc, char **argv) {

    key_t key = ftok(".", 2021);
    int sem_id;
    if ((sem_id = semget(key, 1, IPC_CREAT | 0666)) < 0) {
        perror("semget");
        exit(EXIT_FAILURE);
    }

    struct sembuf sbuff;
    sbuff.sem_num = 0;
    sbuff.sem_op = atoi(argv[1]);
    printf("sem_op = %d\n", sbuff.sem_op);
    sbuff.sem_flg = SEM_UNDO;
    if (semop(sem_id, &sbuff, 1) == -1) {
        perror("semop");
        exit(EXIT_FAILURE);
    }
    printf("semop success\n");
    

    return 0;
}